#include "WindowAPI.h"

#include "Core/GlobalContext.h"

#include "Platform/Windows/WindowsAPI.h"

namespace SE
{
	Ref<WindowAPI> WindowAPI::Create(const WindowAPIType type)
	{
		switch (type)
		{
			default: SE_ASSERT(false, "Unkown window api type!"); return nullptr;
			case WindowAPIType::GLFW: return CreateRef<WindowsAPI>();
		}
	}

	WindowAPIType WindowAPI::GetAPIType()
	{
		return GlobalContext::GetWindowAPI()->getAPIType();
	}

	void WindowAPI::MakeContextCurrent(const Ref<WindowContext>& context)
	{
		GlobalContext::GetWindowAPI()->makeContextCurrent(context);
	}

	void WindowAPI::SetTitle(const String& title)
	{
		GlobalContext::GetWindowAPI()->setTitle(title);
	}

	void WindowAPI::SetVSync(const Boolean vsync)
	{
		GlobalContext::GetWindowAPI()->setVSync(vsync);
	}

	void WindowAPI::SetCursorFocused(const Boolean focused)
	{
		GlobalContext::GetWindowAPI()->setCursorFocused(focused);
	}

	void WindowAPI::PollEvents()
	{
		GlobalContext::GetWindowAPI()->pollEvents();
	}

	void WindowAPI::SwapBuffers()
	{
		GlobalContext::GetWindowAPI()->swapBuffers();
	}

	Vector2i WindowAPI::GetWindowSize()
	{
		return GlobalContext::GetWindowAPI()->getWindowSize();
	}

	Vector2f WindowAPI::GetMousePosition()
	{
		return GlobalContext::GetWindowAPI()->getMousePosition();
	}

	Boolean WindowAPI::IsMouseButtonPressed(const MouseButton button)
	{
		return GlobalContext::GetWindowAPI()->isMouseButtonPressed(button);
	}

	Boolean WindowAPI::IsKeyboardButtonPressed(const KeyboardButton button)
	{
		return GlobalContext::GetWindowAPI()->isKeyboardButtonPressed(button);
	}
} // !namespace SE